<?php
class IndexController extends Controller{
	private $path;//	保存路径信息
	public $db;//保存数据库信息
	public $page;
	public function __construct(){
		$this->path = ROOT_PATH . '/mdb/data.php';
		$this->db = include $this->path;
	}
	
	public function index(){


		$this->assign('data', $this->db);
		$this->display();

	}

	public function ajax_add_message(){
		 // 验证码判断 
		 
$errorStr =<<<str
<script type="text/javascript">
//$('.code').parent('li').find('span').html('验证码错误');
alert('验证码错误');
</script>
str;
$okStr =<<<str
<script type="text/javascript">
$('.code').parent('li').find('span').html('ok');
</script>
str;
 		if(IS_POST){
			if(strtoupper($_POST['code'])	!= $_SESSION['code']){
				 $code =0;				
				$_POST['code'] = $code;
				echo json_encode($_POST);
				return false;
			}else{
				$code =1;
			}
		}
		$_POST['code'] = $code;
		$this->db[] = $_POST;
		data_to_file($this->db, $this->path);
		echo json_encode($_POST);
	}
	 public function code(){
		$code =new Code();
		$code->ImgCodeShow();
	 }
}
?>